prolog './gnum.ijs'
NB. numeric constants ---------------------------------------------------

9!:11 ] 6
3j4      -: ". '3j4'
1 _2 3j4 -: ". '1 _2 3j4'

0.34     -: ". '0.34'
3j4 0.34 -: ". '3j4 0.34'

0 -: 0x1
0 -: 0p1
0 -: 0x2
0 -: 0p2
0 -: 0x0
0 -: 0p0

x -: ". ": x=:?3 4$10000
x -: ". ": x=:_1e4+?3 4$2e4
x -: ". ": x=:j./?2 3 4$10000
x -: ". ": x=:j./_1e4+?2 3 4$2e4

x -: ". ":     ,.x=:  _1e9+?20$2e9
x -: ". ":!.16 ,.x=:o._1e9+?20$2e9
x -: ". ":!.16 ,.x=:j./  _1e9+?2 20$2e9

(^1 2)        -: ". '1x1 1x2 '
((^1),1+%:_1) -: ". '1x1 1j1 '
((^1),o.1)    -: ". '1x1 1p1 '

((o.1)^1 2)   -: ". '1p1 1p2'

7 82   -: ". '2b111 5b312 '
4.6 2 0.5 0.5 1 0.5   -: ". '2.3b20 2.3b2 2b.1 2b0.1 _2b1 _2b1.1 '

0j4 _5        -: ". '4ad90 5ar3.14159265358979'

((%3),_0.25)  -: ". '    1r3 _1r4'

eq=: -:&(3!:1)
1 2 _  3.4 eq ". '1 2 _  3.4'
1 2 _  3j4 eq ". '1 2 _  3j4'
1 2 __ 3.4 eq ". '1 2 __ 3.4'
1 2 __ 3j4 eq ". '1 2 __ 3j4'
1 2 _. 3.4 eq ". '1 2 _. 3.4'
1 2 _. 3j4 eq ". '1 2 _. 3j4'

'_. 3'       -: ": _. 3
'_. 3'       -: ": _. 3.0
'_. 3'       -: ": _. 3j0
'_. 3.14159' -: ": _. 1p1
'_. 2.71828' -: ": _. 1x1

x=: 1e4 ?@$ IF64{2e9 9e18
x    eq ". ":  x
(-x) eq ". ": -x

(4=type x) *. 0 = (- y) - x=:  ". '_',":    y=: 2^IF64{31 63x
(4=type x) *. 0 = (<:y) - x=:  ".     ": <: y=: 2^IF64{31 63x

1=type@> 0;1;0 1
4=type@> 00;01
8=type@> 1.2;1.0;1.;1. 0
16=type@> 1j4;1j0;0 1j0
64=type@> 123x;123 0x
128=type@> 2r3;0r0;2r1;2r1 0

'ill-formed number' -: ". etx '3ee4'
'ill-formed number' -: ". etx '3jj4'
'ill-formed number' -: ". etx '_b_'
'ill-formed number' -: ". etx '6b_'
'ill-formed number' -: ". etx '6b__'
'ill-formed number' -: ". etx '6b.'

NB. verify large b-type integers on 64-bit
3 : 0 ''
if. -. IF64 do. 1 return. end.
assert. 16b123456789abcdef =!.0 ] 81985529216486895
assert. 16 = 3!:0 ] 16b123456789abcdef 2j2
assert. 8 = 3!:0 ] 16b123456789abcdef 4.2
assert. 4 = 3!:0 ] 16b123456789abcdef 3
assert. 16b123456789abcdef 3 = 81985529216486896 3
assert. (0 ". '16b123456789abcdef') =!.0 ] 81985529216486895
assert. 16 = 3!:0 ] (0 ". '16b123456789abcdef 2j2')
assert. 8 = 3!:0 ] (0 ". '16b123456789abcdef 4.2')
assert. 4 = 3!:0 ] (0 ". '16b123456789abcdef 3')
assert. (0 ". '16b123456789abcdef 3') = 81985529216486896 3
1
)




epilog''

